<?php
namespace app\admin\model;

use think\Db;
use think\Model;

class User extends Model
{
    //设置当前模型对应数据表名称
    protected $table = 'am_user';

    //查询用户表所有数据
    public function selectAll()
    {
        $res = $this->field('*')->select();
        //var_dump($res);
        return $res;
    }

    //添加用户
    public function addUser($data)
    {
        $res = $this->data($data)->save();
        return $res;
    }

    //修改用户
    public function updateUser($id)
    {
        $res = $this->field('*')->where('id='.$id)->find();
        return $res;
    }

    //更新用户
    public function editUser($data,$id)
    {
        $res = $this->allowField('*')->save($data,['id'=>$id]);
        return $res;
    }

    //删除用户
    public function deleteUser($id)
    {
        $res = $this->field('*')->where('id',$id)->delete();
    }
}